//
// Created by Administrator on 2019/5/31 0031.
//

#ifndef RTMPDEMO_VIDEOCHANNEL_H
#define RTMPDEMO_VIDEOCHANNEL_H


#include <x264.h>
#include "librtmp/rtmp.h"

class VideoChannel {
    typedef void (*VideoCallback)(RTMPPacket *packet);

public:
    void setVideoEncInfo(int width, int height, int fps, int bitrate);

    void encodeData(int8_t *data);

    void setVideoCallback(VideoCallback callback);
private:
    int mWidth;
    int mHeight;
    int mFps;
    int mBitrate;
    int ySize;
    int uvSize;
    x264_t *videoCodec;
    //一帧
    x264_picture_t *pic_in;

    void sendSpsPps(uint8_t sps[100], uint8_t pps[100], int len, int pps_len);

    VideoCallback videoCallback;

    void sendFrame(int type, uint8_t *payload, int i_payload);
};


#endif //RTMPDEMO_VIDEOCHANNEL_H
